const dateFormatMd = function (originVal) {
    if (!originVal) {
        return ''
    }
    let date = originVal.split(" ")[0]
    let dates = date.replace(/\-/g, '/')
    const dt = new Date(dates)

    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + '').padStart(2, '0')

    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')
    return `${m}-${d}`
    // return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
}
const dateFormatY = function (originVal) {
    if (!originVal) {
        return ''
    }
    let date = originVal.split(" ")[0]
    let dates = date.replace(/\-/g, '/')
    const dt = new Date(dates)

    const y = dt.getFullYear()
    const m = (dt.getMonth() + 1 + '').padStart(2, '0')
    const d = (dt.getDate() + '').padStart(2, '0')

    const hh = (dt.getHours() + '').padStart(2, '0')
    const mm = (dt.getMinutes() + '').padStart(2, '0')
    const ss = (dt.getSeconds() + '').padStart(2, '0')
    return y
    // return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
}
const stringLengthC = function (originVal) {
    let str = originVal || ''
    if (str.length > 35) {
        return str.substr(0, 35) + '...'
    } else {
        return str
    }
}
const stringLengthT = function (originVal) {
    let str = originVal || ''
    if (str.length > 16) {
        return str.substr(0, 16) + '...'
    } else {
        return str
    }

}
const stringLengthWork = function (originVal) {
    let str = originVal || ''
    if (str.length > 9) {
        return str.substr(0, 9) + '...'
    } else {
        return str
    }
}
const returnIndex = function (originVal) {
    let str = (originVal || '' + '').toFixed(0)
    if (str.length == 1) {
        return '00' + originVal
    }
    if (str.length == 2) {
        return '0' + originVal
    }
    if (str.length == 3) {
        return originVal
    } else {
        return originVal
    }

}
export {
    dateFormatMd,
    dateFormatY,
    stringLengthC,
    stringLengthT,
    stringLengthWork,
    returnIndex
}